<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{{ url_for('static',filename='layuiadmin/layui/css/layui.css') }}" media="all">
    <link rel="stylesheet" href="{{ url_for('static',filename='layuiadmin/style/admin.css') }}" media="all">

</head>

<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form" style="padding-bottom: 10px">
                        <div class="layui-input-inline">
                            <input type="text" name="user_id" autocomplete="off"
                                   placeholder="用户手机号" class="layui-input">
                            <input type="hidden" name="status" autocomplete="off" class="layui-input" value="{{ 0 }}">
                            <input type="hidden" name="w_type" autocomplete="off" class="layui-input"
                                   value="{{ w_type or '' }}">
                        </div>

                        <div class="layui-input-inline " style="width: 90px">
                            <button class="layui-btn" id="searchEmailCompany" data-type="reload">
                                <i class="layui-icon" style="font-size: 20px; "></i> 搜索
                            </button>
                        </div>
                    </form>


                    <table class="layui-hide" id="test-table" lay-filter="test-table"></table>
                    <script type="text/html" id="test-table-barDemo">
                        <a class="layui-btn layui-btn" lay-event="edit">成功</a>
                        <a class="layui-btn-danger layui-btn" lay-event="del">失败</a>
                    </script>

                </div>
            </div>
        </div>
    </div>

</div>

<!-- 展示图片大小 -->
<style type="text/css">
    .layui-table-cell {
        text-align: center;
        height: auto;
        white-space: normal;
    }

    .layui-table img {
        max-width: 100px
    }
</style>


<!-- 添加和修改的弹出层开始 -->
<div style="display: none;padding: 20px" id="saveOrUpdateDiv">
    <form class="layui-form " action="" lay-filter="dataFrm" id="dataFrm">


        <input type="hidden" name="order_id" id="order_id">
        <input type="hidden" name="status" value="{{ status }}">
        <input type="hidden" name="w_type" value="{{ w_type or '' }}">
        <input type="hidden" name="user_id_" value="{{ user_id or '' }}">

        <div class="layui-form-item" style="margin-top:40px; ">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="doSubmit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>


    </form>
</div>
<!-- 添加和修改的弹出层结束 -->


<script src="{{ url_for('static',filename='layuiadmin/layui/layui.js') }}"></script>
<script>
    layui.config({
        base: '../../../static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'jquery', 'layer', 'form', 'upload'], function () {
        var admin = layui.admin;
        var table = layui.table;
        var upload = layui.upload;
        var $ = layui.jquery;
        var data_status = $("input[name='status']").val();
        var data_type = $("input[name='w_type']").val();
        var data_user_id = $("input[name='user_id_']").val();
        console.log(data_status);
        console.log(data_user_id);

        show_img = function (t) {
            var t = $(t).find("img");
            //页面层
            layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area:['70%','90%'], //宽高
                //area: [$(t).width + 'px', $(t).height + 'px'], //宽高
                shadeClose: true, //开启遮罩关闭
                end: function (index, layero) {
                    return false;
                },
                content: '<div style="text-align:center"><img src="' + $(t).attr('src') + '" /></div>'
            });
        };


        var tableIns = table.render({
            title: '充值未审核订单',
            toolbar: true,
            elem: '#test-table',
            url: '/cms/orders/recharge_orders_info/?status=' + data_status + '&user_id=' + data_user_id + '&w_type=' + data_type,
            cellMinWidth: 80,
            cols: [[
                {field: 'order_id', title: 'ID', align: 'center', hide: true,},
                {field: 'username', title: '用户名', align: 'center'},
                {field: 'phone', title: '手机号', align: 'center'},
                {field: 'price', title: '金额', sort: true, align: 'center'},
                {
                    field: 'order_img',
                    title: '付款凭证',
                    align: 'center',
                    templet: function (d) {
                        return '<div onclick="show_img(this)" ><img src="' + d.order_img + '" alt="" width="100px" height="100px"></a></div>';
                    }

                },
                {field: 'trade_no', title: '订单号', align: 'center',},
                {field: 'w_type', title: '充值类型', align: 'center',},
                {field: 'create_time', title: '创建时间', sort: true, align: 'center'},
                {field: 'status', title: '状态', sort: true, align: 'center'},
                {align: 'center', fixed: 'right', title: '操作', toolbar: '#test-table-barDemo'}
            ]]
            , page: true
        });


        //监听工具条
        table.on('tool(test-table)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                layer.confirm('您确定要成功么?', function (index) {
                    $.ajax({
                        url: '/cms/orders/recharge_order_success/',
                        type: "POST",
                        data: data,
                        success: function (data) {
                            if (data['code'] == 200) {
                                layer.msg("成功", {icon: 6});
                                tableIns.reload()
                            } else {
                                layer.msg(data['message'], {icon: 5});
                            }
                        }
                    });
                });
            } else if (obj.event === 'del') {
                layer.confirm('您确定要取消么?', function (index) {
                    $.ajax({
                        url: '/cms/orders/recharge_order_cancel/',
                        type: "POST",
                        data: data,
                        success: function (data) {
                            if (data['code'] == 200) {
                                //显示提示框
                                layer.msg("成功", {icon: 6});
                                tableIns.reload()
                            } else {
                                layer.msg(data['message'], {icon: 5});
                            }
                        }
                    });
                });
            }


        });

    });


</script>
</body>
</html>